package com.example.upload.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinIOConfig {

    private String url;
    private String accessKey;
    private String secretKey;
    private String secure;
 
    @Bean
    public MinioClient buildMinioClient() {
        return MinioClient
                .builder()
                .credentials(accessKey, secretKey)
                .endpoint(url)
                .region("cn-west-1") // 正确设置地区
                .build();
    }
}